/**
 * @file Fiber.h
 * @author  haifeng (haifengxiao@icloud.com)
 * @brief
 * @version 0.1
 * @date 2021-07-17
 *
 * @copyright Copyright (c) 2021
 *
 */

#pragma once

#include <memory>
#include <functional>

class Scheduler;

namespace Chen {

    class Fiber : public std::enable_shared_from_this<Fiber> {
        friend Scheduler;
    public:
        typedef std::shared_ptr<Fiber> ptr;
        enum State {
            /// 初始化状态
            INIT,
            /// 暂停状态
            HOLD,
            /// 执行中状态
            EXEC,
            /// 结束状态
            TERM,
            /// 可执行状态
            READY,
            /// 异常状态
            EXCEPT
        };
        uint64_t GetFiberId() { return m_id; }

    private:
        uint64_t m_id = 0;
    };

}//namespace Chen